package mylittleinvestigations.CaseInformation;

import java.io.IOException;
import java.util.*;

public class FlagManager
{
    private HashMap<String, Boolean> namedFlagDictionary;

    public FlagManager()
    {
        this.namedFlagDictionary = new HashMap<String, Boolean>();
    }

    public boolean IsFlagSet(String flagName)
    {
        if (!this.namedFlagDictionary.containsKey(flagName))
        {
            this.namedFlagDictionary.put(flagName, false);
        }

        return this.namedFlagDictionary.get(flagName);
    }

    public void SetFlag(String flagName)
    {
        this.namedFlagDictionary.put(flagName, true);
    }

    public void ClearFlag(String flagName)
    {
        this.namedFlagDictionary.put(flagName, false);
    }
    
    public void Reset()
    {
        this.namedFlagDictionary.clear();
    }

    void SaveToXml(CaseXmlWriter writer) throws IOException
    {
        writer.StartElement("FlagManager");
        writer.EndElement();
    }

    FlagManager(CaseXmlReader reader)
    {
        this.namedFlagDictionary = new HashMap<String, Boolean>();
        
        reader.StartElement("FlagManager");
        reader.EndElement();
    }
}